package org.dmcs.homework.statistics.classifiers.implementations;

import java.util.List;
import java.util.Map;

import org.dmcs.homework.statistics.classifiers.api.IStopCriterion;

/**
 * Decides whether the classification loop should stop basing on the number of classes
 * at decision time.
 * @author Zielony
 * @version 1.0
 */
public class ClassCountStopCriterion implements IStopCriterion {
	/**
	 * The minimal number of classes acceptable.
	 */
	private int minimalClassCount;
	
	/**
	 * The constructor configuring the minimal number of classes acceptable.
	 * @param minimalClassCount minimal number of classes acceptable.
	 */
	public ClassCountStopCriterion(int minimalClassCount) {
		this.minimalClassCount = minimalClassCount;
	}
	
	/**
	 * {@inheritDoc}
	 */
	public boolean shouldStop(Map<Integer, List<Integer>> classes,
			double[][] data) {
		/*
		 * If the actual number of classes is lesser or equal the minimum, stopping
		 * the classification.
		 */
		if(classes.size() <= minimalClassCount) {
			return true;
		}
		else {
			return false;
		}
	}
}